//OQL表达式
var oqlExpressions = (function () {
  return [
    //扩展字段
    {
      name: "扩展字段",
      filter: function (attribute) {
        return attribute.DataTypeFlag === 0 && attribute.DescFlexFieldDef;
      },
      expressions: [
        {
          code: "SegName",
          name: "扩展字段名称",
          SQLType: "NVARCHAR(1000)",
          filter: function (attribute) {
            return (
              attribute.DescFlexFieldDef.ValueSetDef.ValidateType === 1 ||
              attribute.DescFlexFieldDef.ValueSetDef.ValidateType === 3 ||
              attribute.DescFlexFieldDef.ValueSetDef.ValidateType === 4
            );
          },
          expression: function (attribute) {
            let exprArr = attribute.fullExpression.split(".");
            exprArr.pop();
            exprArr.push("CombineName");
            let combineNameExpr = exprArr.join(".");
            let number =
              attribute.Name.indexOf("PrivateDescSeg") >= 0
                ? attribute.DescFlexFieldDef.Number + 50
                : attribute.DescFlexFieldDef.Number;
            return (
              "fn_GetSegName(" + combineNameExpr + ",'#@#'," + number + ")"
            );
          },
        },
        {
          code: "ToInt",
          name: "转整数",
          SQLType: "INT",
          filter: function (attribute) {
            return (
              attribute.DescFlexFieldDef.ValueSetDef.ValidateType === 2 &&
              attribute.DescFlexFieldDef.ValueSetDef.ValueType === 1
            );
          },
          expression: function (attribute) {
            return (
              "case when isnull(" +
              attribute.fullExpression +
              ", '') = '' then 0 else convert(int," +
              attribute.fullExpression +
              ") end"
            );
          },
        },
        {
          code: "ToDate",
          name: "转日期",
          SQLType: "DATETIME",
          filter: function (attribute) {
            return (
              attribute.DescFlexFieldDef.ValueSetDef.ValidateType === 2 &&
              (attribute.DescFlexFieldDef.ValueSetDef.ValueType === 3 ||
                attribute.DescFlexFieldDef.ValueSetDef.ValueType === 6)
            );
          },
          expression: function (attribute) {
            return (
              "case when isnull(" +
              attribute.fullExpression +
              ", '') = '' then null else convert(datetime," +
              attribute.fullExpression +
              ") end"
            );
          },
        },
        {
          code: "ToDecimal",
          name: "转十进制数",
          SQLType: function (attribute) {
            return (
              "DECIMAL(24, " +
              attribute.DescFlexFieldDef.ValueSetDef.Pricision +
              ")"
            );
          },
          filter: function (attribute) {
            return (
              attribute.DescFlexFieldDef.ValueSetDef.ValidateType === 2 &&
              attribute.DescFlexFieldDef.ValueSetDef.ValueType === 4
            );
          },
          expression: function (attribute) {
            return (
              "case when isnull(" +
              attribute.fullExpression +
              ", '') = '' then 0.0 else convert(decimal(24," +
              attribute.DescFlexFieldDef.ValueSetDef.Pricision +
              ")," +
              attribute.fullExpression +
              ") end"
            );
          },
        },
        {
          code: "ToBit",
          name: "转布尔",
          SQLType: "BIT",
          filter: function (attribute) {
            return (
              attribute.DescFlexFieldDef.ValueSetDef.ValidateType === 2 &&
              attribute.DescFlexFieldDef.ValueSetDef.ValueType === 5
            );
          },
          expression: function (attribute) {
            return (
              "case when isnull(" +
              attribute.fullExpression +
              ", '') = '' then 0 else convert(bit," +
              attribute.fullExpression +
              ") end"
            );
          },
        },
      ],
    },
    //字符串
    {
      name: "字符串",
      filter: function (attribute) {
        return (
          attribute.DataTypeFlag === 0 &&
          attribute.DataTypeKey.FullName === "System.String"
        );
      },
      expressions: [
        {
          code: "NoNull",
          name: "非Null",
          SQLType: function (attribute) {
            return (
              "NVARCHAR(" +
              (attribute.Length > 0 ? attribute.Length : "MAX") +
              ")"
            );
          },
          expression: function (attribute) {
            return "isnull(" + attribute.fullExpression + ",'')";
          },
        },
        {
          code: "Len",
          name: "字符串长度",
          SQLType: function (attribute) {
            return attribute.Length > 0 ? "INT" : "BIGINT";
          },
          expression: function (attribute) {
            return "sqlLen(" + attribute.fullExpression + ")";
          },
        },
        {
          code: "Left",
          name: "取左子串",
          SQLType: function (attribute) {
            return (
              "NVARCHAR(" +
              (attribute.Length > 0 ? attribute.Length : "MAX") +
              ")"
            );
          },
          expression: function (attribute) {
            return (
              "sqlLeft(" +
              attribute.fullExpression +
              "," +
              attribute.Length +
              ")"
            );
          },
        },
        {
          code: "Right",
          name: "取右子串",
          SQLType: function (attribute) {
            return (
              "NVARCHAR(" +
              (attribute.Length > 0 ? attribute.Length : "MAX") +
              ")"
            );
          },
          expression: function (attribute) {
            return (
              "sqlRight(" +
              attribute.fullExpression +
              "," +
              attribute.Length +
              ")"
            );
          },
        },
        {
          code: "Trim",
          name: "去掉字符串左右两侧的空格",
          SQLType: function (attribute) {
            return (
              "NVARCHAR(" +
              (attribute.Length > 0 ? attribute.Length : "MAX") +
              ")"
            );
          },
          expression: function (attribute) {
            return "sqlLTrim(sqlRTrim(" + attribute.fullExpression + "))";
          },
        },
        {
          code: "LTrim",
          name: "去掉字符串左侧的空格",
          SQLType: function (attribute) {
            return (
              "NVARCHAR(" +
              (attribute.Length > 0 ? attribute.Length : "MAX") +
              ")"
            );
          },
          expression: function (attribute) {
            return "sqlLTrim(" + attribute.fullExpression + ")";
          },
        },
        {
          code: "RTrim",
          name: "去掉字符串右侧的空格",
          SQLType: function (attribute) {
            return (
              "NVARCHAR(" +
              (attribute.Length > 0 ? attribute.Length : "MAX") +
              ")"
            );
          },
          expression: function (attribute) {
            return "sqlRTrim(" + attribute.fullExpression + ")";
          },
        },
        {
          code: "Replace",
          name: "字符串替换",
          SQLType: function (attribute) {
            return (
              "NVARCHAR(" +
              (attribute.Length > 0 ? attribute.Length : "MAX") +
              ")"
            );
          },
          expression: function (attribute) {
            return "sqlReplace(" + attribute.fullExpression + ",'old','new')";
          },
        },
        {
          code: "Lcase",
          name: "字符串变成小写",
          SQLType: function (attribute) {
            return (
              "NVARCHAR(" +
              (attribute.Length > 0 ? attribute.Length : "MAX") +
              ")"
            );
          },
          expression: function (attribute) {
            return "sqlLcase(" + attribute.fullExpression + ")";
          },
        },
        {
          code: "Ucase",
          name: "字符串变成大写",
          SQLType: function (attribute) {
            return (
              "NVARCHAR(" +
              (attribute.Length > 0 ? attribute.Length : "MAX") +
              ")"
            );
          },
          expression: function (attribute) {
            return "sqlUcase(" + attribute.fullExpression + ")";
          },
        },
        {
          code: "Substr",
          name: "取子串",
          SQLType: function (attribute) {
            return (
              "NVARCHAR(" +
              (attribute.Length > 0 ? attribute.Length : "MAX") +
              ")"
            );
          },
          expression: function (attribute) {
            return "sqlSubstr(" + attribute.fullExpression + ",1,1)";
          },
        },
        {
          code: "Reverse",
          name: "反转字符串",
          SQLType: function (attribute) {
            return (
              "NVARCHAR(" +
              (attribute.Length > 0 ? attribute.Length : "MAX") +
              ")"
            );
          },
          expression: function (attribute) {
            return "reverse(" + attribute.fullExpression + ")";
          },
        },
      ],
    },
    //整数
    {
      name: "整数",
      filter: function (attribute) {
        return (
          attribute.DataTypeFlag === 0 &&
          attribute.DataTypeKey.FullName === "System.Int32"
        );
      },
      expressions: [
        {
          code: "Ceiling",
          name: "取最大整数",
          SQLType: "INT",
          expression: function (attribute) {
            return "sqlCeiling(" + attribute.fullExpression + ")";
          },
        },
        {
          code: "Floor",
          name: "取最小整数",
          SQLType: "INT",
          expression: function (attribute) {
            return "sqlFloor(" + attribute.fullExpression + ")";
          },
        },
        {
          code: "Sum",
          name: "合计",
          SQLType: "INT",
          expression: function (attribute) {
            return "sum(" + attribute.fullExpression + ")";
          },
        },
        {
          code: "Max",
          name: "最大值",
          SQLType: "INT",
          expression: function (attribute) {
            return "max(" + attribute.fullExpression + ")";
          },
        },
        {
          code: "Min",
          name: "最小值",
          SQLType: "INT",
          expression: function (attribute) {
            return "min(" + attribute.fullExpression + ")";
          },
        },
      ],
    },
    //长整数
    {
      name: "长整数",
      filter: function (attribute) {
        return (
          attribute.DataTypeFlag === 0 &&
          attribute.DataTypeKey.FullName === "System.Int64"
        );
      },
      expressions: [
        {
          code: "CreatedOn",
          name: "创建时间",
          SQLType: "DATETIME",
          filter: function (attribute) {
            return attribute.Name === "ID";
          },
          expression: function (attribute) {
            let arr = attribute.fullExpression.split(".");
            arr.pop();
            return arr.join(".").concat(".CreatedOn");
          },
        },
        {
          code: "CreatedBy",
          name: "创建人",
          SQLType: "NVARCHAR(50)",
          filter: function (attribute) {
            return attribute.Name === "ID";
          },
          expression: function (attribute) {
            let arr = attribute.fullExpression.split(".");
            arr.pop();
            return arr.join(".").concat(".CreatedBy");
          },
        },
        {
          code: "ModifiedOn",
          name: "修改时间",
          SQLType: "DATETIME",
          filter: function (attribute) {
            return attribute.Name === "ID";
          },
          expression: function (attribute) {
            let arr = attribute.fullExpression.split(".");
            arr.pop();
            return arr.join(".").concat(".ModifiedOn");
          },
        },
        {
          code: "ModifiedBy",
          name: "修改人",
          SQLType: "NVARCHAR(50)",
          filter: function (attribute) {
            return attribute.Name === "ID";
          },
          expression: function (attribute) {
            let arr = attribute.fullExpression.split(".");
            arr.pop();
            return arr.join(".").concat(".ModifiedBy");
          },
        },
        {
          code: "SysVersion",
          name: "SysVersion",
          SQLType: "BIGINT",
          filter: function (attribute) {
            return attribute.Name === "ID";
          },
          expression: function (attribute) {
            let arr = attribute.fullExpression.split(".");
            arr.pop();
            return arr.join(".").concat(".SysVersion");
          },
        },
        {
          code: "Ceiling",
          name: "取最大整数",
          SQLType: "BIGINT",
          expression: function (attribute) {
            return "sqlCeiling(" + attribute.fullExpression + ")";
          },
        },
        {
          code: "Floor",
          name: "取最小整数",
          SQLType: "BIGINT",
          expression: function (attribute) {
            return "sqlFloor(" + attribute.fullExpression + ")";
          },
        },
        {
          code: "Sum",
          name: "合计",
          SQLType: "BIGINT",
          expression: function (attribute) {
            return "sum(" + attribute.fullExpression + ")";
          },
        },
        {
          code: "Max",
          name: "最大值",
          SQLType: "BIGINT",
          expression: function (attribute) {
            return "max(" + attribute.fullExpression + ")";
          },
        },
        {
          code: "Min",
          name: "最小值",
          SQLType: "BIGINT",
          expression: function (attribute) {
            return "min(" + attribute.fullExpression + ")";
          },
        },
      ],
    },
    //日期/日期时间
    {
      name: "日期/日期时间",
      filter: function (attribute) {
        return (
          attribute.DataTypeFlag === 0 &&
          (attribute.DataTypeKey.FullName === "System.Date" ||
            attribute.DataTypeKey.FullName === "System.DateTime")
        );
      },
      expressions: [
        {
          code: "yyyy-MM-dd HH:mm:ss",
          name: "格式:年-月-日 时:分:秒",
          SQLType: "VARCHAR(20)",
          expression: function (attribute) {
            return (
              "convert(varchar(20), " + attribute.fullExpression + ", 120)"
            );
          },
        },
        {
          code: "yyyy-MM-dd",
          name: "格式:年-月-日",
          SQLType: "VARCHAR(10)",
          expression: function (attribute) {
            return "convert(varchar(10), " + attribute.fullExpression + ", 23)";
          },
        },
        {
          code: "yyyy.MM.dd",
          name: "格式:年.月.日",
          SQLType: "VARCHAR(10)",
          expression: function (attribute) {
            return (
              "convert(varchar(10), " + attribute.fullExpression + ", 102)"
            );
          },
        },
        {
          code: "yyyy/MM/dd",
          name: "格式:年/月/日",
          SQLType: "VARCHAR(10)",
          expression: function (attribute) {
            return (
              "convert(varchar(10), " + attribute.fullExpression + ", 111)"
            );
          },
        },
        {
          code: "yyyyMMdd",
          name: "格式:年月日",
          SQLType: "VARCHAR(10)",
          expression: function (attribute) {
            return (
              "convert(varchar(10), " + attribute.fullExpression + ", 112)"
            );
          },
        },
        {
          code: "Year",
          name: "年",
          SQLType: "INT",
          expression: function (attribute) {
            return "sqlYear(" + attribute.fullExpression + ")";
          },
        },
        {
          code: "Quarter",
          name: "季度",
          SQLType: "INT",
          expression: function (attribute) {
            return "datepart(quarter," + attribute.fullExpression + ")";
          },
        },
        {
          code: "Month",
          name: "月",
          SQLType: "INT",
          expression: function (attribute) {
            return "sqlMonth(" + attribute.fullExpression + ")";
          },
        },
        {
          code: "Day",
          name: "天",
          SQLType: "INT",
          expression: function (attribute) {
            return "sqlDay(" + attribute.fullExpression + ")";
          },
        },
        {
          code: "DateDiffDay",
          name: "相隔天数",
          SQLType: "INT",
          expression: function (attribute) {
            return "datediff(day," + attribute.fullExpression + ",getdate())";
          },
        },
        {
          code: "DateDiffMonth",
          name: "相隔月",
          SQLType: "INT",
          expression: function (attribute) {
            return "datediff(month," + attribute.fullExpression + ",getdate())";
          },
        },
        {
          code: "DateDiffYear",
          name: "相隔年",
          SQLType: "INT",
          expression: function (attribute) {
            return "datediff(year," + attribute.fullExpression + ",getdate())";
          },
        },
        {
          code: "DateDiffHour",
          name: "相隔小时",
          SQLType: "INT",
          expression: function (attribute) {
            return "datediff(hour," + attribute.fullExpression + ",getdate())";
          },
        },
        {
          code: "DateDiffMinute",
          name: "相隔分",
          SQLType: "INT",
          expression: function (attribute) {
            return (
              "datediff(minute," + attribute.fullExpression + ",getdate())"
            );
          },
        },
        {
          code: "DateDiffSecond",
          name: "相隔秒",
          SQLType: "INT",
          expression: function (attribute) {
            return (
              "datediff(second," + attribute.fullExpression + ",getdate())"
            );
          },
        },
        {
          code: "DateAddDay",
          name: "加天数",
          SQLType: "DATETIME",
          expression: function (attribute) {
            return "dateadd(d,1," + attribute.fullExpression + ")";
          },
        },
        {
          code: "DateAddMonth",
          name: "加月份",
          SQLType: "DATETIME",
          expression: function (attribute) {
            return "dateadd(m,1," + attribute.fullExpression + ")";
          },
        },
        {
          code: "DateAddQuarter",
          name: "加季度",
          SQLType: "DATETIME",
          expression: function (attribute) {
            return "dateadd(q,1," + attribute.fullExpression + ")";
          },
        },
        {
          code: "DateAddYear",
          name: "加年",
          SQLType: "DATETIME",
          expression: function (attribute) {
            return "dateadd(yy,1," + attribute.fullExpression + ")";
          },
        },
        {
          code: "DateAddHour",
          name: "加小时",
          SQLType: "DATETIME",
          expression: function (attribute) {
            return "dateadd(hh,1," + attribute.fullExpression + ")";
          },
        },
        {
          code: "DateAddMinute",
          name: "加分钟",
          SQLType: "DATETIME",
          expression: function (attribute) {
            return "dateadd(mi,1," + attribute.fullExpression + ")";
          },
        },
        {
          code: "DateAddSecond",
          name: "加秒",
          SQLType: "DATETIME",
          expression: function (attribute) {
            return "dateadd(s,1," + attribute.fullExpression + ")";
          },
        },
        {
          code: "Max",
          name: "最大值",
          SQLType: "DATETIME",
          expression: function (attribute) {
            return "max(" + attribute.fullExpression + ")";
          },
        },
        {
          code: "Min",
          name: "最小值",
          SQLType: "DATETIME",
          expression: function (attribute) {
            return "min(" + attribute.fullExpression + ")";
          },
        },
      ],
    },
    //十进制数
    {
      name: "十进制数",
      filter: function (attribute) {
        return (
          attribute.DataTypeFlag === 0 &&
          attribute.DataTypeKey.FullName === "System.Decimal"
        );
      },
      expressions: [
        {
          code: "Round2Digits",
          name: "保留两位小数",
          SQLType: function (attribute) {
            return "DECIMAL(" + attribute.Precision + ",2)";
          },
          expression: function (attribute) {
            return "sqlRound(" + attribute.fullExpression + ",2)";
          },
        },
        {
          code: "RoundByPrecision",
          name: "保留精度小数位",
          SQLType: function (attribute) {
            return (
              "DECIMAL(" + attribute.Precision + "," + attribute.Scale + ")"
            );
          },
          filter: function (attribute) {
            if (attribute.Stereotypes && attribute.Stereotypes.length > 0) {
              return attribute.Stereotypes.some(
                (stereotype) =>
                  stereotype.Name === "MoneyAmountRelationAttribute" &&
                  stereotype.TaggedValues.length > 0
              );
            }
            return false;
          },
          expression: function (attribute) {
            let stereotype = attribute.Stereotypes.find(
              (stereotype) => stereotype.Name === "MoneyAmountRelationAttribute"
            );
            if (
              !stereotype ||
              !stereotype.TaggedValues ||
              stereotype.TaggedValues.length === 0
            )
              return "";
            let typeTaggedValue = stereotype.TaggedValues.find(
              (taggedValue) => taggedValue.Name === "Type"
            );
            if (!typeTaggedValue) return "";
            let toAttributeTaggedValue = stereotype.TaggedValues.find(
              (taggedValue) => taggedValue.Name === "ToAttribute"
            );
            if (!toAttributeTaggedValue) return "";
            let precisionExpr = toAttributeTaggedValue.Value;
            let precisionExprArr = precisionExpr.split(".");
            //反向路径
            let reversePaths = [];
            reversePaths.push(attribute.metedata.Name);
            reversePaths = reversePaths.concat(
              precisionExprArr.slice(0, precisionExprArr.length - 1)
            );
            //正向路径
            let positivePaths = [];
            positivePaths.push(attribute.metedata.Name);
            let parentAttribute = attribute.parentAttribute;
            while (parentAttribute) {
              positivePaths.unshift(parentAttribute.metedata.Name);
              parentAttribute = parentAttribute.parentAttribute;
            }
            while (reversePaths.length > 0) {
              if (positivePaths[positivePaths.length - 1] === reversePaths[0]) {
                positivePaths.pop();
                reversePaths.shift();
              } else {
                break;
              }
            }
            let pathArr = attribute.fullExpression.split(".");
            pathArr.pop();
            let pPaths = pathArr
              .slice(0, positivePaths.length + 1)
              .concat(reversePaths);
            pPaths.push(precisionExprArr[precisionExprArr.length - 1]);
            if (typeTaggedValue.Value === "UOM")
              precisionExpr = pPaths.join(".").concat(".Round.Precision");
            if (typeTaggedValue.Value === "Price")
              precisionExpr = pPaths.join(".").concat(".PriceRound.Precision");
            if (typeTaggedValue.Value === "Money")
              precisionExpr = pPaths.join(".").concat(".MoneyRound.Precision");
            return (
              "sqlRound(" + attribute.fullExpression + "," + precisionExpr + ")"
            );
          },
        },
        {
          code: "Ceiling",
          name: "取最大整数",
          SQLType: function (attribute) {
            return (
              "DECIMAL(" + attribute.Precision + "," + attribute.Scale + ")"
            );
          },
          expression: function (attribute) {
            return "sqlCeiling(" + attribute.fullExpression + ")";
          },
        },
        {
          code: "Floor",
          name: "取最小整数",
          SQLType: function (attribute) {
            return (
              "DECIMAL(" + attribute.Precision + "," + attribute.Scale + ")"
            );
          },
          expression: function (attribute) {
            return "sqlFloor(" + attribute.fullExpression + ")";
          },
        },
        {
          code: "Sum",
          name: "合计",
          SQLType: function (attribute) {
            return (
              "DECIMAL(" + attribute.Precision + "," + attribute.Scale + ")"
            );
          },
          expression: function (attribute) {
            return "sum(" + attribute.fullExpression + ")";
          },
        },
        {
          code: "Max",
          name: "最大值",
          SQLType: function (attribute) {
            return (
              "DECIMAL(" + attribute.Precision + "," + attribute.Scale + ")"
            );
          },
          expression: function (attribute) {
            return "max(" + attribute.fullExpression + ")";
          },
        },
        {
          code: "Min",
          name: "最小值",
          SQLType: function (attribute) {
            return (
              "DECIMAL(" + attribute.Precision + "," + attribute.Scale + ")"
            );
          },
          expression: function (attribute) {
            return "min(" + attribute.fullExpression + ")";
          },
        },
      ],
    },
    //布尔
    {
      name: "布尔",
      filter: function (attribute) {
        return (
          attribute.DataTypeFlag === 0 &&
          attribute.DataTypeKey.FullName === "System.Boolean"
        );
      },
      expressions: [
        {
          code: "YesNo",
          name: "是/否",
          SQLType: "NVARCHAR(10)",
          expression: function (attribute) {
            return (
              "(case when isnull(" +
              attribute.fullExpression +
              ",0) = 1 then '是' else '否' end)"
            );
          },
        },
      ],
    },
    //实体
    {
      name: "实体",
      filter: function (attribute) {
        return attribute.DataTypeFlag === 1;
      },
      expressions: [
        {
          code: "Code",
          name: "编码",
          SQLType: "NVARCHAR(1000)",
          filter: function (attribute) {
            return (
              !attribute.children ||
              attribute.children.length === 0 ||
              attribute.children.some((childAttribute) => {
                return childAttribute.Name === "Code";
              })
            );
          },
          expression: function (attribute) {
            return attribute.fullExpression.concat(".Code");
          },
        },
        {
          code: "Name",
          name: "名称",
          SQLType: "NVARCHAR(1000)",
          filter: function (attribute) {
            return (
              !attribute.children ||
              attribute.children.length === 0 ||
              attribute.children.some((childAttribute) => {
                return childAttribute.Name === "Name";
              })
            );
          },
          expression: function (attribute) {
            return attribute.fullExpression.concat(".Name");
          },
        },
        {
          code: "RoundPrecision",
          name: "精度",
          SQLType: "INT",
          filter: function (attribute) {
            return attribute.DataTypeKey.FullName === "UFIDA.U9.Base.UOM.UOM";
          },
          expression: function (attribute) {
            return attribute.fullExpression.concat(".Round.Precision");
          },
        },
        {
          code: "PriceRoundPrecision",
          name: "单价精度",
          SQLType: "INT",
          filter: function (attribute) {
            return (
              attribute.DataTypeKey.FullName ===
              "UFIDA.U9.Base.Currency.Currency"
            );
          },
          expression: function (attribute) {
            return attribute.fullExpression.concat(".PriceRound.Precision");
          },
        },
        {
          code: "MoneyRoundPrecision",
          name: "金额精度",
          SQLType: "INT",
          filter: function (attribute) {
            return (
              attribute.DataTypeKey.FullName ===
              "UFIDA.U9.Base.Currency.Currency"
            );
          },
          expression: function (attribute) {
            return attribute.fullExpression.concat(".MoneyRound.Precision");
          },
        },
        {
          code: "DisplayName",
          name: "账簿期间名称",
          SQLType: "NVARCHAR(50)",
          filter: function (attribute) {
            return (
              attribute.DataTypeKey.FullName ===
              "UFIDA.U9.Base.SOB.SOBAccountingPeriod"
            );
          },
          expression: function (attribute) {
            return attribute.fullExpression.concat(".DisplayName");
          },
        },
        {
          code: "ReportPeriodsDisplay",
          name: "账簿期间显示名称",
          SQLType: "NVARCHAR(50)",
          filter: function (attribute) {
            return (
              attribute.DataTypeKey.FullName ===
              "UFIDA.U9.Base.SOB.SOBAccountingPeriod"
            );
          },
          expression: function (attribute) {
            return attribute.fullExpression.concat(".ReportPeriodsDisplay");
          },
        },
        // {
        //     code: 'DocNo',
        //     name: '单号',
        //     SQLType: 'NVARCHAR(1000)',
        //     filter: function (attribute) {
        //         return !attribute.children || attribute.children.length === 0 || attribute.children.some((childAttribute) => {
        //             return childAttribute.Name === "DocNo";
        //         });
        //     },
        //     expression: function (attribute) {
        //         return attribute.fullExpression.concat(".DocNo");
        //     }
        // },
        // {
        //     code: 'BusinessDate',
        //     name: '日期',
        //     SQLType: 'DATETIME',
        //     filter: function (attribute) {
        //         return !attribute.children || attribute.children.length === 0 || attribute.children.some((childAttribute) => {
        //             return childAttribute.Name === "BusinessDate";
        //         });
        //     },
        //     expression: function (attribute) {
        //         return attribute.fullExpression.concat(".BusinessDate");
        //     }
        // },
        {
          code: "CreatedOn",
          name: "创建时间",
          SQLType: "DATETIME",
          expression: function (attribute) {
            return attribute.fullExpression.concat(".CreatedOn");
          },
        },
        {
          code: "CreatedBy",
          name: "创建人",
          SQLType: "NVARCHAR(50)",
          expression: function (attribute) {
            return attribute.fullExpression.concat(".CreatedBy");
          },
        },
        {
          code: "ModifiedOn",
          name: "修改时间",
          SQLType: "DATETIME",
          expression: function (attribute) {
            return attribute.fullExpression.concat(".ModifiedOn");
          },
        },
        {
          code: "ModifiedBy",
          name: "修改人",
          SQLType: "NVARCHAR(50)",
          expression: function (attribute) {
            return attribute.fullExpression.concat(".ModifiedBy");
          },
        },
        {
          code: "SysVersion",
          name: "SysVersion",
          SQLType: "BIGINT",
          expression: function (attribute) {
            return attribute.fullExpression.concat(".SysVersion");
          },
        },
      ],
    },
    //枚举
    {
      name: "枚举",
      filter: function (attribute) {
        return attribute.DataTypeFlag === 3;
      },
      expressions: [
        {
          code: "Code",
          name: "编码",
          SQLType: "NVARCHAR(255)",
          expression: function (attribute) {
            return (
              "sqlF_Sys_GetEnumCode('" +
              attribute.DataTypeKey.FullName +
              "'," +
              attribute.fullExpression +
              ")"
            );
          },
        },
        {
          code: "Name",
          name: "名称",
          SQLType: "NVARCHAR(255)",
          expression: function (attribute) {
            return (
              "GetEnumName('" +
              attribute.DataTypeKey.FullName +
              "'," +
              attribute.fullExpression +
              ")"
            );
          },
        },
      ],
    },
  ];
})();
